#!/usr/bin/python3
# -*- coding: UTF-8 -*-

from app import App
from utils.tools import Tools
from utils.element import Element

import gol
gol._init()
from os import popen as osPopen, path as osPath  # 管道处理


class Application(App):
    # 初始配置
    def __init__(self):
        super().__init__()


class Action(App):
    # 初始配置
    def __init__(self):
        super().__init__()

        self.iDefMin = 5
        self.iDefMax = 10
        self.iVideoTime = 30

    def init(self):
        sAction = self.sAction
        if (sAction=='up' or sAction=='upl' or sAction=='left'):
            iLen = 800
            if (self.iLen):
                iLen = self.iLen
            self.goRun(sAction, iLen)




    # 重复动作
    def goRun(self, sType = 'up', iLen = 800):
        i = 0
        pos = self.tool.moveDirection(sType)
        while i < iLen:
            i += 1
            iRan = self.tool.getRandom(8, 15)
            print('执行次数：%d, 时长：%d' % (i, iRan)) # 打印

            self.tool.move(pos)
            self.tool.setSleep(iRan)



action = Action()
action.init()